package main

import (
	"day5/user-sage/auth-service/basic/handler/service"
	inits2 "day5/user-sage/auth-service/basic/inits"
	"day5/user-sage/auth-service/basic/proto"
	"day5/user-sage/auth-service/config"
	"flag"
	"fmt"
	"log"
	"net"
)

var (
	port = flag.Int("port", 50051, "The server port")
)

func main() {

	config.Init()

	inits2.Mysql()

	inits2.Redis()
	flag.Parse()
	lis, err := net.Listen("tcp", fmt.Sprintf(":%d", *port))
	if err != nil {
		log.Fatalf("failed to listen: %v", err)
	}
	s := grpc.NewServer()
	__.RegisterUserServer(s, &service.Service{})
	log.Printf("server listening at %v", lis.Addr())
	if err := s.Serve(lis); err != nil {
		log.Fatalf("failed to serve: %v", err)
	}
}
